import request from '@/utils/request'
//新增帖子
export function addPost(data) {
  return request({
    method: 'POST',
    url: '/commentservice/comment-post/addPostByToken',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  }).then(res => res.data)
}

//获取时间排序帖子
export function getPosts(page, limit, isPrivate, value, typeId, ptypeId) {
  return request({
    method: 'POST',
    url: `/commentservice/comment-post/getPostListByCommentQueryVoAndTokenOrderByCreatTime/${page}/${limit}`,
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      isPrivate,
      value: value,
      typeId: typeId,
      ptypeId: ptypeId
    }
  }).then(res => res.data)
}

export function getPostsByLike(page, limit, isPrivate, value, typeId, ptypeId) {
  return request({
    method: 'POST',
    url: `/commentservice/comment-post/getPostListByCommentQueryVoAndTokenOrderByLike/${page}/${limit}`,
    headers: {
      'Content-Type': 'application/json'
    },
    data: {
      isPrivate,
      value: value,
      typeId: typeId,
      ptypeId: ptypeId
    }
  }).then(res => res.data)
}

//根据id获取信息
export function getIdPost(id) {
  return request({
    method: 'GET',
    url: `/commentservice/comment-post/getPostInfoByTokenAndPostId/${id}`,
    headers: {
      'Content-Type': 'application/json'
    },
  }).then(res => res.data)
}

//点赞过的帖子
export function getLikesPost(page, limit) {
  return request({
    method: 'POST',
    url: `/commentservice/comment-post/getLikedPostListByToken/${page}/${limit}`,
  }).then(res => res.data)
}

//收藏过的帖子
export function getCollectsPost(page, limit) {
  return request({
    method: 'POST',
    url: `/commentservice/comment-post/getCollectedPostListByToken/${page}/${limit}`,
  }).then(res => res.data)
}

//获取时间排序帖子
export function getPostsAdministration(page, limit, userid) {
  return request({
    method: 'POST',
    url: `/commentservice/comment-post/getPostListByCommentQueryVoAndTokenOrderByCreatTime/${page}/${limit}`,
    data:{
      userId:userid
    }
  }).then(res => res.data)
}

//删除帖子
export function delPosts(id) {
  return request({
    method: 'DELETE',
    url: `/commentservice/comment-post/deletePostByPostId/${id}`,
  }).then(res => res.data)
}

//修改帖子
export function modPosts(id, data) {
  return request({
    method: 'PUT',
    url: `/commentservice/comment-post/updatePostByPostId/${id}`,
    data
  }).then(res => res.data)
}